<?php
/**
 * sdPHP
 * @author     码农<8044023@qq.com>
 * @copyright  sdPHP
 * @license    https://gitee.com/cq8044023/sdphp
 */
namespace sdphp\lib;
use sdphp\lib\CoreBase\PortManagr;
class SwooleServerTcp{
    protected $_config;
    protected $SwooleServerWebSocket;
    public function start(SwooleServerWebSocket $SwooleServerWebSocket){
        $this->SwooleServerWebSocket=$SwooleServerWebSocket;
        $this->_config=$this->SwooleServerWebSocket->_portManagr->portConfig[PortManagr::SOCK_TCP];
        $tcp_server = $this->SwooleServerWebSocket->_server->addListener($this->_config["socket_name"], $this->_config["socket_port"], SWOOLE_SOCK_TCP);
        $tcp_server->set(PortManagr::setServer($this->_config["pack_tool"]));
        $tcp_server->on("receive",[$this,"onReceive"]);
    }
    public function onReceive($serv, $fd, $threadId, $data){ 
        $stdObj=new \stdClass();
        $stdObj->serv       =$serv;
        $stdObj->fd         =$fd;
        $stdObj->threadId   =$threadId;
        $stdObj->request    =$this->SwooleServerWebSocket->_packs->start($this->_config["pack_tool"])->unPack($data);
        
        var_dump($stdObj);
        
    }
}

?>